package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.*;
import com.burgeon.backend.EnterpriseWeChat.service.EWAppEmpService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;

@RestController
@CrossOrigin
@RequestMapping("ewapp/sale")
public class EWAppEmpController extends EWBaseController {
    @Autowired
    private EWAppEmpService ewAppEmpService;

    /**
     *导购/店铺看板
     * @return
     */
    @RequestMapping("getSaleData")
    public ResponseResult<SaleStoreData> getSaleStoreData(String token,String empPhone){
        SaleStoreData data = ewAppEmpService.EmpSaleKanBan(token, empPhone);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 导购看板
     * @param token
     * @return
     */
    @RequestMapping("getSalerData")
    public ResponseResult<SaleData> getSalerData( String token,String empPhone){
        SaleData data = ewAppEmpService.SaleKanBan(token, empPhone);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     *店铺销售看板
     * @param token
     * @param phone
     * @return
     */
    @RequestMapping("getStoreData")
    public ResponseResult<StoreData> getStoreData(String token, String phone){
        Long s = System.currentTimeMillis();
        System.err.println("导购的手机号"+phone);
        StoreData data = ewAppEmpService.storeKanBan(token, phone);
        Long e = System.currentTimeMillis();
        System.err.println(e-s);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 会员升降级
     * @param token
     * @param storeId
     * @return
     */
    @RequestMapping("FindRFIMByStoreId")
    public ResponseResult<ArrayList<RFIMVipCount>> FindRFIMByStoreId(String token, String storeId){
        ArrayList<RFIMVipCount> data = ewAppEmpService.FindRFIMByStoreId(token,storeId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 订单评价
     * @param token
     * @param empId
     * @return
     */
    @RequestMapping("GetYcValueActionByEmpId")
    public ResponseResult<ArrayList<YcValueAction>> GetYcValueActionByEmpId(String token, String empId){
        ArrayList<YcValueAction> data = ewAppEmpService.GetYcValueActionByEmpId(token, empId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 最新
     * @param token
     * @param empId
     * @return
     */
    @RequestMapping("GetNewestYcValue")
    public ResponseResult<ArrayList<YcValueAction>> GetNewestYcValue(String token, String empId){
        ArrayList<YcValueAction> data = ewAppEmpService.GetNewestYcValue(token, empId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 好中差
     * @param token
     * @param empId
     * @param type
     * @return
     */
    @RequestMapping("GetStatusYcValue")
    public ResponseResult<ArrayList<YcValueAction>> GetStatusYcValue(String token, String empId,int type){
        ArrayList<YcValueAction> data = ewAppEmpService.GetStatusYcValue(token, empId,type);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 订单和订单详情
     * @param token
     * @param storeId
     * @param status
     * @return
     */
    @RequestMapping("GetYcOrder")
    public ResponseResult<ArrayList<YCOrder>> GetYcOrder(String token, String storeId,String status,int page){
        System.err.println("status=================="+status);
        ArrayList<YCOrder>data = ewAppEmpService.GetYcOrder(token, storeId, status,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 全部订单
     * @param token
     * @param storeId
     * @return
     */
    @RequestMapping("GetYcOrderAll")
    public ResponseResult<ArrayList<YCOrder>> GetYcOrderAll(String token, String storeId,int page){
        ArrayList<YCOrder>data = ewAppEmpService.GetYcOrderAll(token, storeId,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 总会员信息（导购/店铺）
     * @param token
     * @param empId
     * @param storeId
     * @param page
     * @return
     */
    @RequestMapping("GetVipData")
    public ResponseResult<ArrayList<Vip>> GetVipData(String token,String empId, String storeId,int page){
        ArrayList<Vip>data = ewAppEmpService.GetVipDataByEmpId(token, empId, storeId, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 新增会员（导购/店铺）
     * @param token
     * @param empId
     * @param storeId
     * @param page
     * @return
     */
    @RequestMapping("GetNewVip")
    public ResponseResult<ArrayList<Vip>> GetNewVip(String token,String empId, String storeId,int page){
        ArrayList<Vip>data = ewAppEmpService.GetNewVipByEmpId(token, empId, storeId, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 导购会销额
     * @param token
     * @param empId
     * @param page
     * @return
     */
    @RequestMapping("GetRetailByEmpId")
    public ResponseResult<ArrayList<RetailVo> > GetRetailByEmpId(String token, String empId, int page){
        ArrayList<RetailVo>   data = ewAppEmpService.GetRetailByEmpId(token, empId, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 店铺会销额
     * @param token
     * @param page
     * @return
     */
    @RequestMapping("GetRetailByStoreId")
    public ResponseResult<ArrayList<RetailVo> > GetRetailByStoreId(String token,String storeId,int page){
        ArrayList<RetailVo>  data = ewAppEmpService.GetRetailByStoreId(token,storeId,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 充值金额（导购/店铺）
     * @param token
     * @param empId
     * @param storeId
     * @param page
     * @return
     */
    @RequestMapping("GetVipDeposit")
    public ResponseResult<ArrayList<VipDeposit>> GetVipDeposit(String token,String empId, String storeId,int page){
        ArrayList<VipDeposit> data = ewAppEmpService.GetVipDeposit(token, empId,storeId, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 会员预警
     * @param token
     * @param warningType
     * @param storeId
     * @return
     */
    @RequestMapping("queryVipWarning")
    public ResponseResult<ArrayList<Vip>> queryVipWarning(String token,String warningType, String storeId,int page){
        ArrayList<Vip> data = ewAppEmpService.queryVipWarning(token,warningType,storeId,page);
        return new ResponseResult<>(SUCCESS,data);
    }


    /**
     * 搜索会员
     * @param token
     * @param cardNo
     * @return
     */
    @RequestMapping("findVipByCardNo")
    public ResponseResult<Vip> findVipByCardNo(String token,String cardNo,String empId,String storeId,String type){
        Vip data = ewAppEmpService.FindVipByCardNo(token,cardNo,empId,storeId,type);
        return new ResponseResult<>(SUCCESS,data);
    }


}
